package com.zenith.article.controller;

import com.zenith.article.po.domain.ArtTag;
import com.zenith.article.po.dto.ArtTagDTO;
import com.zenith.article.service.ArtTagService;
import com.zenith.common.annotation.request.SecurePostMapping;
import com.zenith.common.result.Result;
import com.zenith.common.result.PageResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 文章标签控制器
 *
 * @author zenith
 * @since 2025-08-29
 */
@RestController
@RequestMapping("/api/article/tag")
@Tag(name = "文章标签管理", description = "文章标签相关接口")
public class ArtTagController {

    @Autowired
    private ArtTagService artTagService;

    /**
     * 分页查询文章标签
     */
    @Operation(summary = "分页查询文章标签")
    @SecurePostMapping("/getArtTagPage")
    public Result<PageResult<ArtTag>> getArtTagPage(ArtTagDTO query) {
        PageResult<ArtTag> pageResult = artTagService.getArtTagPage(query);
        return Result.success(pageResult);
    }

    /**
     * 创建文章标签
     */
    @Operation(summary = "创建文章标签")
    @SecurePostMapping("/createArtTag")
    public Result<Boolean> createArtTag(@RequestBody ArtTagDTO tagDTO) {
        boolean result = artTagService.createArtTag(tagDTO);
        return Result.success(result);
    }

    /**
     * 更新文章标签
     */
    @Operation(summary = "更新文章标签")
    @SecurePostMapping("/updateArtTag")
    public Result<Boolean> updateArtTag(@RequestBody ArtTagDTO tagDTO) {
        boolean result = artTagService.updateArtTag(tagDTO);
        return Result.success(result);
    }

    /**
     * 删除文章标签
     */
    @Operation(summary = "删除文章标签")
    @SecurePostMapping("/deleteArtTag/{id}")
    public Result<Boolean> deleteArtTag(@PathVariable Long id) {
        boolean result = artTagService.deleteArtTag(id);
        return Result.success(result);
    }
}